package com.zb;

import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PreDestroy;

@Configuration
@EnableConfigurationProperties(ThreadPoolProperties.class)
public class ThreadPoolAutoConfiguration {


    @Bean
    @ConditionalOnMissingBean
    public ThreadPoolFactory threadPoolFactory(ThreadPoolProperties properties,
                                               MeterRegistry meterRegistry) {
        ThreadPoolFactory threadPoolFactory = new ThreadPoolFactory(properties, meterRegistry);
        ThreadPoolUtils.init(threadPoolFactory);
        return threadPoolFactory;
    }
}
